Skip to main content
Version: 6.0.0-beta.3 - 6.0.0-beta.4

sha3

sha3

Helper function that will sha3 any value using keccak256. Internally it will use Buffer.from(input, 'utf8') to process the input first. If you want to hash a hexString or ByteArray, use TronWeb.utils.ethersUtils.keccak256(input).

Usage

TronWeb.sha3(value);

Parameters

ParameterDescriptionData Type
stringThe string that needs to be hashed using Keccak-256 SHA3 algorithm.String
prefixthe result includes 0x prefix if set as trueBoolean

Returns

String - The result hashed using the Keccak-256 SHA3 algorithm.

Example


> var hash = TronWeb.sha3("some string to be hashed");
console.log(hash)
> '0xc4b9bbe7eb8797cf2818085dbcd6ea6662b3261c28810c318e079c8d0c691da6'
> var hashOfHash = TronWeb.sha3(hash, false)
> '0xc4b9bbe7eb8797cf2818085dbcd6ea6662b3261c28810c318e079c8d0c691da6'